package br.com.tcf.login;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

public class UsuarioMaster extends Usuario implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String cpf;
	private String nm_usuario;
	private String senha;

	public UsuarioMaster() {
		this.cpf = "555.555.555-55";
		this.senha = algoritmoSenha();
		this.nm_usuario = "MASTER";
		
		super.cpf = this.cpf;
		super.nm_usuario = this.nm_usuario;
		super.senha = this.senha;
		super.sn_administrador = true;
	}

//	public String algoritmoCpf() {
//		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
//
//		String data = sdf.format(new Date());
//
//		return data+"111";
//	}

	public String algoritmoSenha() {
		SimpleDateFormat sdfHora = new SimpleDateFormat("HH");
		SimpleDateFormat sdfDia = new SimpleDateFormat("dd");
		SimpleDateFormat sdfMes = new SimpleDateFormat("MM");

		Integer hora = Integer.valueOf(sdfHora.format(new Date()));
		Integer dia = Integer.valueOf(sdfDia.format(new Date())) * 2;
		Integer mes = Integer.valueOf(sdfMes.format(new Date())) * 3;
		
		return String.valueOf(String.valueOf(hora)+String.valueOf(dia)+String.valueOf(mes));
	}
	
	public Boolean validaUsuarioMaster(String cpf, String senha) {
		if(this.senha.equals(senha) && this.cpf.equals(cpf)){
			return true;
		}else{
			return false;
		}
	}
	
	@Override
	public String toString() {
		return this.nm_usuario;
	}
}
